package com.hhq.common.domain.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.Date;

/**
 * <p>Description: 通用自动模型 </p>
 *
 * @author : xiaodong.yang
 * @date : 2024/1/5 15:07
 */
@Setter
@Getter
@MappedSuperclass
public class BaseModel {

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "native")
    @ApiModelProperty(value = "主键")
    private Integer id;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    @Column(columnDefinition = "int(11) default null comment '创建人'")
    private Integer createUser;
    /**
     * 创建人名称
     */
    @ApiModelProperty(value = "创建人名称")
    @Column(columnDefinition = "varchar(255) default '' comment '创建人名称'")
    private String createUserName;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @Column(nullable = false, columnDefinition = "datetime(6) null on update current_timestamp(6)  comment '创建时间'")
    private Date createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    @Column(columnDefinition = "int(11) default null comment '更新人'")
    private Integer updateUser;
    /**
     * 更新人名称
     */
    @ApiModelProperty(value = "更新人名称")
    @Column(columnDefinition = "varchar(255) default '' comment '更新人名称'")
    private String updateUserName;
    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @Column(nullable = false, columnDefinition = "datetime(6) null on update current_timestamp(6)  comment '更新时间'")
    private Date updateTime;
    /**
     * 是否删除：0-否；1-是
     */
    @ApiModelProperty(value = "是否删除：0-否；1-是")
    @TableLogic
    @Column(columnDefinition = "bit(1) default 0 comment '是否删除：0-否；1-是'")
    private boolean deleted;
}
